<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		<meta charset="utf-8" />
		<title></title>
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link href="static/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="static/css/ace.min.css" />
		<link rel="stylesheet" href="static/css/ace-skins.min.css" />
		<link rel="stylesheet" href="static/assets/css/font-awesome.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="static/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />
		<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="static/js/jquery.tips.js"></script>
<script type="text/javascript">
	
	
	
	//保存
	function save(){
		var ids ="" ;
		$("input:checkbox[name='ids']:checked").each(function() {
			ids += $(this).val() + ",";
		});
		ids.substring(0,ids.length-1) ;
		$("#ARRAY_IDS").val(ids) ;
			if($("#NAME").val()==""){
			$("#NAME").tips({
				side:3,
	            msg:'请输入标题名',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#NAME").focus();
			return false;
		}
		
// 		if($("#ICON").val()==""){
// 			$("#ICON").tips({
// 				side:3,
// 	            msg:'请输入图标URL',
// 	            bg:'#AE81FF',
// 	            time:2
// 	        });
// 			$("#ICON").focus();
// 			return false;
// 		}
		if($("#STATUS").val()==""){
			$("#STATUS").tips({
				side:3,
	            msg:'请输入标签状态',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#STATUS").focus();
			return false;
		}
		if($("#C_ID").val()==""){
			$("#C_ID").tips({
				side:3,
	            msg:'请输入所属公司ID',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#C_ID").focus();
			return false;
		}
		if($("#TYPE_ID").val()==""){
			$("#TYPE_ID").tips({
				side:3,
	            msg:'请输入所属类型ID',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#TYPE_ID").focus();
			return false;
		}
		 $.ajax({
	            url: 'companyDynamic/addDynamic',
	            type: 'post',//提交的方式
	            dataType:'json',
	            data:  $("#Form1").serialize() ,
	            success: function(msg) {
	                //这是成功返回的数据，写自己的逻辑
	                if(msg.result=='ok') {
	                	$("#Form2").submit() ;
	 				   $("#zhongxin").hide();
	 					$("#zhongxin2").show();
	                } else {
	                	alert("发布失败") ;
	                	 $("#zhongxin").hide();
		 				$("#zhongxin2").show();
	                }
	            }
	        });
	}
</script>
	</head>
<body><!--  -->
	<form action="#" name="Form1" id="Form1" method="post">
		<div id="zhongxin">
		<table id="table_report" class="table table-striped table-bordered table-hover">
			<tr>
				<th>分类：</th>
				<td>
				<input type="hidden" name="typeIDs" id="ARRAY_IDS" />
					<c:forEach var="type" items="${list}" varStatus="vs">
					<input  type="checkbox" name="ids" value="${type.ID}" /><span class="lbl">${type.NAME}</span>
						<c:if test="${vs.index+1}%4==0">
							<br/>
						</c:if>
					</c:forEach>
				</td>
			</tr>
			<tr>
				<th>添加自定义分类:</th>
				<td><input type="text" name="infoType" id="ICON" maxlength="32" placeholder="这里输入添加自定义分类" title="添加自定义分类"/></td>
			</tr>
			<tr>
				<th>主标题:</th>
				<td><input type="text" name="MAIN_TITLE" id="STATUS"  maxlength="32" style="width:95%;" placeholder="这里输入主标题" title="主标题"/></td>
			</tr>
			<tr>
				<th>副标题:</th>
				<td><input type="text" name="ASSIST_TITLE" id="C_ID"  maxlength="32" style="width:95%;" placeholder="这里输入副标题" title="副标题"/></td>
			</tr>
			<tr>
				<th>内容:</th>
				<td><textarea type="text" name="CONTENT" id="TYPE_ID"  maxlength="32" style="width:95%;" placeholder="这里输入内容" title="内容"></textarea></td>
			</tr>
		</table>
		</div>
		<div id="zhongxin2" class="center" style="display:none"><br/><br/><br/><br/><br/><img src="static/images/jiazai.gif" /><br/><h4 class="lighter block green">提交中...</h4></div>
	</form><!-- -->
	<form action="companyDynamic/addPicture.action" name="Form2" id="Form2" method="post"  enctype="multipart/form-data">
	<table id="table_report" class="table table-striped table-bordered table-hover">
		<tr>
				<th>上传图片:</th>
				<td><input type="file" name="file" id="TYPE_ID"  maxlength="32" style="width:95%;" placeholder="这里输入内容" title="内容"></input><br>
				<input type="file" name="file" id="TYPE_ID"  maxlength="32" style="width:95%;" placeholder="这里输入内容" title="内容"></input><br>
				<input type="file" name="file" id="TYPE_ID"  maxlength="32" style="width:95%;" placeholder="这里输入内容" title="内容"></input><br>
				<input type="file" name="file" id="TYPE_ID"  maxlength="32" style="width:95%;" placeholder="这里输入内容" title="内容"></input></td>
			</tr>
			<tr>
				<td style="text-align: center;" colspan="2">
					<a class="btn btn-mini btn-primary" onclick="save();">保存</a>
					<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
				</td>
			</tr>
	</table>
	</form>
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="static/js/bootstrap.min.js"></script>
		<script src="static/js/ace-elements.min.js"></script>
		<script src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript">
		$(top.hangge());
		$(function() {
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
		});
		
		</script>
</body>
</html>